package com.qch.concurrent.demo_02_countdownLatch;

import java.util.concurrent.CountDownLatch;

/**
 * @Author qch
 * @Date 2021/8/2
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(5);
        //如果只有4，main线程会一直阻塞
        for (int i = 0; i < 5; i++) {
            new MyThread("线程"+(i+1),countDownLatch).start();
        }
        //main线程等待
        countDownLatch.await();
        System.out.println("main线程执行结束");
    }
}
